//
//  YGShoppingCartViewController.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/3/10.
//

#import "YGShoppingCartViewController.h"
#import "YGGoodsTableViewCell.h"
#import "YGPayView.h"

@interface YGShoppingCartViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *goodsTableView;
@property (nonatomic, strong) YGPayView *payView;
@property (nonatomic, strong) NSArray *goodsList;



@end

@implementation YGShoppingCartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];
    [self initconstraints];
    // Do any additional setup after loading the view.
}

-(void)initView{
    [self.view addSubview:self.goodsTableView];
    [self.view addSubview:self.payView];
}

-(void)initconstraints{
    [self.goodsTableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.view.mas_top).offset(64);
            make.left.right.mas_equalTo(self.view);
            make.bottom.mas_equalTo(self.view.mas_bottom).offset(-110);
    }];
    
    [self.payView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(self.view);
            make.bottom.mas_equalTo(self.view.mas_bottom).offset(50);
            make.height.mas_equalTo(50);
    }];
}

#pragma tableviewDelegate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 136.5;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _goodsList.count;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    YGGoodsTableViewCell *cell = [[YGGoodsTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YGGoodsTableViewCell"];
    return cell;
}

#pragma setter

- (UITableView *)goodsTableView{
    if (!_goodsTableView) {
        _goodsTableView = [[UITableView alloc]init];
        _goodsTableView.delegate= self;
        _goodsTableView.dataSource = self;
        _goodsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_goodsTableView registerClass:YGGoodsTableViewCell.class forCellReuseIdentifier:@"YGGoodsTableViewCell"];
        
    }
    return _goodsTableView;
}

- (YGPayView *)payView{
    if (!_payView) {
        _payView = [[YGPayView alloc]init];
        _payView.backgroundColor = [UIColor whiteColor];
    }
    return _payView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
